package com.anhuanjia.tools.eao.controller;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import org.springframework.util.StringUtils;

import com.alibaba.fastjson.JSON;
import com.anhuanjia.tools.eao.bean.EaoAudit;
import com.anhuanjia.tools.eao.bean.EaoAuditReply;
import com.anhuanjia.tools.eao.bean.EaoProjectDoc;
import com.anhuanjia.tools.eao.bean.EaoProjectInfo;
import com.anhuanjia.tools.eao.bean.EaoProjectStaff;
import com.anhuanjia.tools.eao.bean.EaoReportChapter;
import com.anhuanjia.tools.eao.beanvo.EaoProjectInfoVo;
import com.anhuanjia.tools.eao.beanvo.EaoProjectStaffVo;
import com.anhuanjia.tools.eao.beanvo.EaoSubmitTimeVo;
import com.anhuanjia.tools.eao.code.Constant;
import com.efastsoft.framework.Member;
import com.efastsoft.framework.UIFacade;
import com.efastsoft.framework.annotation.Alias;
import com.efastsoft.framework.annotation.Priv;
import com.efastsoft.framework.annotation.Priv.LoginType;
import com.efastsoft.framework.data.DataRow;
import com.efastsoft.framework.data.DataTable;
import com.efastsoft.framework.data.Q;
import com.efastsoft.framework.data.Transaction;
import com.efastsoft.framework.i18n.Lang;
import com.efastsoft.framework.utility.StringUtil;

/**
 * 审核表操作
 * 
 * @author Administrator
 *
 */

@Alias(value = "audit")
public class AuditUI extends UIFacade {

	/**
	 * 我的审核
	 */
	@Priv(loginType = LoginType.Member)
	public void auditUIState() {
		Long id = Member.getUID();
		int num = 0;
		int numOne = 0;
		int pageSize = this.Request.getInt("PageSize");
		if (pageSize == 0) {
			pageSize = 10;
		}
		int pageIndex = this.Request.getInt("PageIndex");
		// 我的审核中
		Q dataTable = new Q(
				"select count(ea.ProjectNumber) as num , ea.ProjectNumber,ea.ProjectName,ea.ProjectLevel,e.auditType from eao_audit as e ,eao_project_info as ea  where e.stats = '审核中' and ea.PerjectLeader = ?",
				id);
//		DataTable dataTableNum = new Q(
//				"select count(ea.ProjectNumber) as num from eao_audit as e ,eao_project_info as ea  where e.stats = '审核中' and ea.PerjectLeader = ?",
//				id).fetch();
		if (dataTable.fetch(pageSize, pageIndex).getRowCount() > 0) {
			num = dataTable.fetch().get(0).getInt("num");
			this.Response.put("countNum1", num);
			this.Response.put("mhResourceList1", dataTable);
		} else {
			$F("查询我审核的所有信息失败");
		}
		// 我的已审核
		Q dataTableOne = new Q(
				"select count(ea.ProjectNumber) as num , ea.ProjectNumber,ea.ProjectName,ea.ProjectLevel,e.AuditType from eao_audit as e ,eao_project_info as ea  where e.stats = '已审核' and ea.PerjectLeader = ?",
				id);
//		DataTable dataTableNumOne = new Q(
//				"select count(ea.ProjectNumber) as num from eao_audit as e ,eao_project_info as ea  where e.stats = '已审核' and ea.PerjectLeader = ?",
//				id).fetch();
		if (dataTableOne.fetch(pageSize, pageIndex).getRowCount() > 0) {
			numOne = dataTableOne.fetch().get(0).getInt("num");
			this.Response.put("countNum2", numOne);
			this.Response.put("mhResourceList2", dataTableOne.fetch(pageSize, pageIndex));
		} else {
			$F("查询我已审核的所有信息失败");
		}

	}

	/**
	 * 查询本项目的成员人名单
	 */
	@Priv(loginType = LoginType.Member)
	public void findStaffs() {
		String pid = $V("ProjectId");
		DataTable dt = new Q(
				"select GROUP_CONCAT(staff.staffName) as StaffNameId , FullName as StaffNames from eao_project_staff as staff LEFT JOIN Mh_Resource on staff.staffName=Mh_Resource.Member where projectId = ?",
				pid).fetch();
		String Staff_nameId = "";
		for (DataRow dataRow : dt) {
			Staff_nameId = dataRow.getString("StaffNameId");
		}
		this.Response.put("StaffNameId", Staff_nameId);
		$S("data", dt);
	}

	@Priv(loginType = LoginType.Member)
	public void findStaffs2() {
		String pid = $V("ProjectId");
		DataTable dtFour = new Q(
				"select GROUP_CONCAT(StaffName) as StaffName , GROUP_CONCAT(staffsName) as StaffNames from(select  StaffName,projectId,FullName as staffsName from eao_project_staff as staff LEFT JOIN Mh_Resource on staff.staffName=Mh_Resource.Member)as cy where projectId = ? GROUP BY projectId",
				pid).fetch();
		String staffs = ""; // dt4.getString(0, 0); // 项目成员
		String staffsId = ""; // dt4.getString(0, 0); // 项目成员
		for (DataRow drFour : dtFour) {
			staffs = drFour.getString(1);
			staffsId = drFour.getString(0);
		}
		$S("StaffsId", staffsId);
		$S("data", staffs);
	}

	/**
	 * 查询本项目的成员人名单(含负责人)
	 */
	@Priv(loginType = LoginType.Member)
	public void findStaff() {
		String pid = $V("ProjectId");
		DataTable dt = new Q(
				"select  staff.StaffName as Value,FullName as Label from eao_project_staff as staff LEFT JOIN Mh_Resource on staff.staffName=Mh_Resource.Member where projectId =? UNION select  ep.perjectLeader as value,FullName as label from eao_project_info as ep LEFT JOIN Mh_Resource on ep.perjectLeader=Mh_Resource.Member where id = ?",
				pid, pid).fetch();
		$S("data", dt);
	}

	/**
	 * 项目组成员章节分配
	 * 
	 * @param projectStaff
	 */
	@Priv(loginType = LoginType.Member)
	public void findByStaffs() {
		String pid = $V("ProjectId");
		String Report_type = $V("ReportType");// 获取报告类型
		Long userId = Member.getUID();
		// 项目负责人
		List<EaoProjectInfoVo> ProjectInfoVo = new ArrayList<>();
		DataTable dataOne = new Q("select * from eao_project_info where Id = ?", pid).fetch();
		EaoProjectInfo info = new EaoProjectInfo();
		info.setValue(dataOne.get(0));
		EaoProjectInfoVo infoVo = new EaoProjectInfoVo();
		infoVo.setPerjectLeader(info.getPerjectLeader().toString());
		DataTable resourceOne = new Q("select FullName from Mh_Resource where Member = ?", info.getPerjectLeader())
				.fetch();
		if (resourceOne.getRowCount() != 0) {
			infoVo.setLeaderName(resourceOne.getString(0, 0));
		}
		// 项目组成员
		DataTable dt = new Q(
				"select p.perjectLeader , p.ReportType , p.ReportChapter from eao_project_info as p where p.id = ?",
				pid).fetch();
		DataTable data = new Q("select * from eao_project_staff where projectId = ? and StaffName <> ?", pid,
				dt.get(0, 0)).fetch();
		List<EaoProjectStaffVo> projectStaff = new ArrayList<>();
		if (StringUtil.isNotEmpty(Report_type)) {
			String dtOne = new Q("select Item from eao_report_type where ReportId = ?", Report_type).executeString();
			if ("报告表".equals(dtOne)) {
				if (dt.getString(0, 1).equals(dtOne)) {
					if (Constant.Report_Chapter_S.equals(dt.getString(0, 2))) {
						String reportChapter = Constant.Report_Chapter_B;
						this.Response.put("reportChapter", reportChapter);
					} else {
						this.Response.put("reportChapter", dt.getString(0, 2));
					}
				} else {
					String reportChapter = Constant.Report_Chapter_B;
					this.Response.put("reportChapter", reportChapter);
				}
			} else if ("报告书".equals(dtOne)) {
				if (dt.getString(0, 1).equals(dtOne)) {
					if (Constant.Report_Chapter_B.equals(dt.getString(0, 2))) {
						String reportChapter = Constant.Report_Chapter_S;
						this.Response.put("reportChapter", reportChapter);
					} else {
						this.Response.put("reportChapter", dt.getString(0, 2));
					}
				} else {
					String reportChapter = Constant.Report_Chapter_S;
					this.Response.put("reportChapter", reportChapter);
				}
			}
			if (data.getRowCount() != 0) {
				for (DataRow dataRow : data) {
					EaoProjectStaff staff = new EaoProjectStaff();
					staff.setValue(dataRow);
					EaoProjectStaffVo staffVo = new EaoProjectStaffVo();
					staffVo.setId(staff.getId());
					staffVo.setProjectId(staff.getProjectId());
					staffVo.setStaffName(staff.getStaffName());
					DataTable resource = new Q("select FullName from Mh_Resource where Member = ?",
							staff.getStaffName()).fetch();
					for (DataRow newResource : resource) {
						staffVo.setName(newResource.getString("FullName"));
					}
					DataTable dtAllBook = new Q("select * from eao_report_chapter where Type = ? ORDER BY main*1",
							dtOne).fetch();
					List<EaoReportChapter> listdtAllBook = new ArrayList<>();
					for (DataRow dr : dtAllBook) {
						EaoReportChapter entity = new EaoReportChapter();
						entity.setValue(dr);
						listdtAllBook.add(entity);
						staffVo.setReportChapter(listdtAllBook);
					}
					projectStaff.add(staffVo);
				}
			}
			// 查询所有责任人分配章节
			DataTable dtTable = new Q("select * from eao_report_chapter where Type = ? ORDER BY main*1", dtOne).fetch();
			List<EaoReportChapter> list = new ArrayList<EaoReportChapter>();
			if (dtTable.getRowCount() != 0) {
				for (DataRow dr : dtTable) {
					EaoReportChapter entity = new EaoReportChapter();
					entity.setValue(dr);
					list.add(entity);
					infoVo.setReportChapter(list);
				}
			}
		} else {
			String reportChapter = "{\"\":\"\"}";
			this.Response.put("reportChapter", JSON.toJSON(reportChapter));
		}
		if (dt.getString(0, 0).equals(userId.toString())) {
			this.Response.put("S", "1");
		} else {
			this.Response.put("S", "0");
		}
		ProjectInfoVo.add(infoVo);
		this.Response.put("projectStaff", projectStaff);
		this.Response.put("info", ProjectInfoVo);

	}

	/**
	 * 项目组成员章节分配
	 * 
	 * @param projectStaff
	 */
	@Priv(loginType = LoginType.Member)
	public void updateStaffs() {
		Transaction transaction = new Transaction();
		EaoProjectStaff staff = new EaoProjectStaff();
		staff.setValue(this.Request);
		DataTable dt = new Q("select * from eao_project_staff  where Id = ?", staff.getId()).fetch();
		EaoProjectStaff entity = new EaoProjectStaff();
		entity.setValue(dt.get(0));
		entity.setValue(this.Request);
		transaction.update(entity);
		if (transaction.commit()) {
			s("章节分配成功");
		} else {
			f("章节分配失败");
		}
	}

	/**
	 * 项目状态 stats:0 可提交一审 00一审中1可二审11二审中 2可初审22初审中 3可复审33复审中 4可终审44终审中 5审核结束
	 */
	@Priv(loginType = LoginType.Member)
	public void doaudit() {
		String pnumber = $V("ProjectId");
		DataTable dt0 = new Q("select Tof from eao_project_info where Id = ?", pnumber).fetch();
		String iszero = "";
		for (DataRow dr : dt0) {
			iszero = dr.getString(0);
		}
		String isopen = "";
		if ("1".equals(iszero)) {
			DataTable dt = new Q("select Stats from eao_audit where ProjectId =? AND AuditType ='一审'", pnumber).fetch();
			isopen = dt.getString(0, "Stats");
			if (isopen.equals("未提交")) {
				this.Response.put("Stats", "0");
			} else if (isopen.equals("已审核")) {
				DataTable dtTwo = new Q("select Stats from eao_audit where ProjectId =? AND AuditType ='二审'", pnumber)
						.fetch();
				isopen = dtTwo.getString(0, "Stats");
				if (isopen.equals("未提交")) {
					this.Response.put("Stats", "1");
				} else if (isopen.equals("已审核")) {
					DataTable dtThree = new Q("select Stats from eao_audit where ProjectId =? AND AuditType ='初审'",
							pnumber).fetch();
					isopen = dtThree.getString(0, "Stats");
					if (isopen.equals("未提交")) {
						this.Response.put("Stats", "2");
					} else if (isopen.equals("已审核")) {
						DataTable dtFour = new Q("select Stats from eao_audit where ProjectId =? AND AuditType ='复审'",
								pnumber).fetch();
						isopen = dtFour.getString(0, "Stats");
						if (isopen.equals("未提交")) {
							this.Response.put("Stats", "3");
						} else if (isopen.equals("已审核")) {
							DataTable dtFive = new Q(
									"select Stats from eao_audit where ProjectId =? AND AuditType ='终审'", pnumber)
											.fetch();
							isopen = dtFive.getString(0, "Stats");
							if (isopen.equals("未提交")) {
								this.Response.put("Stats", "4");
							} else if (isopen.equals("已审核")) {
								this.Response.put("Stats", "5");
							} else {
								this.Response.put("Stats", "44");
							}
						} else {
							this.Response.put("Stats", "33");
						}
					} else {
						this.Response.put("Stats", "22");
					}
				} else {
					this.Response.put("Stats", "11");
				}
			} else {
				this.Response.put("Stats", "00");
			}
		} else {
			DataTable dtThree = new Q("select Stats from eao_audit where ProjectId =? AND AuditType ='初审'", pnumber)
					.fetch();
			isopen = dtThree.getString(0, "Stats");
			if (isopen.equals("未提交")) {
				this.Response.put("Stats", "2");
			} else if (isopen.equals("已审核")) {
				DataTable dtFour = new Q("select Stats from eao_audit where ProjectId =? AND AuditType ='复审'", pnumber)
						.fetch();
				isopen = dtFour.getString(0, "Stats");
				if (isopen.equals("未提交")) {
					this.Response.put("Stats", "3");
				} else if (isopen.equals("已审核")) {
					DataTable dtFive = new Q("select Stats from eao_audit where ProjectId =? AND AuditType ='终审'",
							pnumber).fetch();
					isopen = dtFive.getString(0, "Stats");
					if (isopen.equals("未提交")) {
						this.Response.put("Stats", "4");
					} else if (isopen.equals("已审核")) {
						this.Response.put("Stats", "5");
					} else {
						this.Response.put("Stats", "44");
					}
				} else {
					this.Response.put("Stats", "33");
				}
			} else {
				this.Response.put("Stats", "22");
			}

		}

	}

	/**
	 * 更改内容表
	 */
	@Priv(loginType = LoginType.Member)
	public void saveOrUpdate() {
		EaoAudit entity = new EaoAudit();
		entity.setValue(this.Request);
		String id = entity.getId();
		DataTable dt = new Q(" select * from eao_audit where Id = ?", id).fetch();
		EaoAudit old = new EaoAudit();
		old.setValue(dt.get(0));
		/*
		 * if (old.getStats().equals("已审核")) { f("审核已关闭，不可更改"); return; }
		 */
		/*
		 * if (old.getAudit_type().equals("二审")) { String pid = old.getProject_id();
		 * DataTable dta = new
		 * Q("select * from eao_audit where project_id = ? and audit_type = ?", pid,
		 * "一审") .fetch(); Audit exentity = new Audit(); exentity.setValue(dta.get(0));
		 * if (exentity.getStats().equals("审核中")) { f("一审未通过，不可更改"); return; } } if
		 * (old.getAudit_type().equals("初审")) { String pid = old.getProject_id();
		 * DataTable dta = new
		 * Q("select * from eao_audit where project_id = ? and audit_type = ?", pid,
		 * "二审") .fetch(); Audit exentity = new Audit(); exentity.setValue(dta.get(0));
		 * if (exentity.getStats().equals("审核中")) { f("二审未通过，不可更改"); return; } } if
		 * (old.getAudit_type().equals("复审")) { String pid = old.getProject_id();
		 * DataTable dta = new
		 * Q("select * from eao_audit where project_id = ? and audit_type = ?", pid,
		 * "初审").fetch(); Audit exentity = new Audit(); exentity.setValue(dta.get(0));
		 * if (exentity.getStats().equals("审核中")) { f("初审未通过，不可更改"); return; } } if
		 * (old.getAudit_type().equals("终审")) { String pid = old.getProject_id();
		 * DataTable dta = new
		 * Q("select * from eao_audit where project_id = ? and audit_type = ?", pid,
		 * "复审").fetch(); Audit exentity = new Audit(); exentity.setValue(dta.get(0));
		 * if (exentity.getStats().equals("审核中")) { f("复审未通过，不可更改"); return; } }
		 */
		old.setValue(this.Request);
		Transaction transaction = new Transaction();
		transaction.update(old);
		if (transaction.commit()) {
			s(Lang.get("Common.ExecuteSuccess"));
		} else {
			f(Lang.get("Common.ExecuteFailed"));
		}

	}

	@Priv(loginType = LoginType.Member)
	public void saveAll() {
		String pid = $V("Project");
		String js;
		if (StringUtils.isEmpty(pid)) {
			f("操作失败");
			return;
		}
		DataTable dt = new Q("Select Tof from eao_project_info where Id= ?", pid).fetch();
		js = dt.get(0, 0).toString();

		for (int i = 0; i < 3; i++) {
			Transaction transaction = new Transaction();
			EaoAudit entity = new EaoAudit();
			EaoAuditReply other = new EaoAuditReply();
			entity.setId(UUID.randomUUID().toString());
			other.setId(UUID.randomUUID().toString());
			other.setAuditId(entity.getId());
			entity.setProjectId(pid);
			entity.setAuditor("");
			entity.setStats("未提交");
			if (i == 0) {
				entity.setAuditType("初审");
			} else if (i == 1) {
				entity.setAuditType("复审");
			} else if (i == 2) {
				entity.setAuditType("终审");
			}
			transaction.insert(other);
			transaction.insert(entity);
			transaction.commit();
		}
		if (js.equals("1")) {
			for (int i = 0; i < 2; i++) {
				Transaction transaction = new Transaction();
				EaoAudit entity = new EaoAudit();
				EaoAuditReply other = new EaoAuditReply();
				entity.setId(UUID.randomUUID().toString());
				other.setId(UUID.randomUUID().toString());
				other.setAuditId(entity.getId());
				entity.setProjectId(pid);
				entity.setAuditor("");
				entity.setStats("未提交");
				if (i == 0) {
					entity.setAuditType("一审");
				} else if (i == 1) {
					entity.setAuditType("二审");
				}
				transaction.insert(other);
				transaction.insert(entity);
				transaction.commit();
			}
		}

	}

	/**
	 * 查询审核流程状态 根据项目编号
	 */
	@Priv(loginType = LoginType.Member)
	public void findOne() {
		String searchKey = $V("SearchKey");
		if (StringUtils.isEmpty(searchKey)) {
			f("请输入搜索条件！");
			return;
		}
		Q q = new Q("select AuditType from eao_audit where ProjectId = ? AND Stats ='审核中' ", searchKey);
		$S("data", q.fetch());
	}

	/**
	 * 查询所有
	 */
	@Priv(loginType = LoginType.Member)
	public void findAll() {
		DataTable dt = new Q("select * from eao_audit ").fetch();
		List<EaoAudit> list = new ArrayList<>();
		for (DataRow dr : dt) {
			EaoAudit entity = new EaoAudit();
			entity.setValue(dr);
			list.add(entity);
			this.Response.put("data", list);
		}
	}

	/**
	 * 根据audit查找（审核人查询自己的审核）
	 */
	@Priv(loginType = LoginType.Member)
	public void findByAuditor() {
		int pageSize = this.Request.getInt("PageSize");
		if (pageSize == 0) {
			pageSize = 10;
		}
		int pageIndex = this.Request.getInt("PageIndex");
		pageIndex = (pageIndex - 1) * pageSize;
		String auditor = "";// $V("Auditor"); // 接收审核人信息 默认为登录人
		auditor = Long.toString(Member.getUID()); // 默认为登录人
		String startTime = $V("StartTime");
		String endTime = $V("EndTime");
		String stats = $V("Stats"); // 审核的状态
		if (StringUtils.isEmpty(auditor)) {
			f("操作失败");
			return;
		}
		if (StringUtils.isEmpty(stats)) {
			f("操作失败");
			return;
		}
		System.out.println(stats);
		if (stats.equals("审核中")) {
			Q q = new Q(
					"select eb.Name,ei.PerjectTime,zb.Stats as Go,ei.Id as Pid,ei.ProjectName,zb.Id,zb.ProjectId,ei.ProjectNumber,ei.ProjectLevel,ei.ReportType,ei.ApprovalUnit,ei.PerjectType as Stats,zb.AuditType,AuditDotime as Audit_date,zb.AuditScore from eao_audit AS zb LEFT JOIN eao_project_info AS ei on zb.ProjectId = ei.Id LEFT JOIN Mh_Branch as eb on ei.company = eb.company and ei.BranchInnerCode = eb.BranchInnerCode where (zb.auditType = '一审' or zb.auditType = '二审' or zb.auditType = '初审' or zb.auditType = '复审' or zb.auditType = '终审' ) and zb.auditor = ? AND zb.Stats != '已审核' ",
					auditor);
//			if (StringUtil.isNotEmpty(startTime) & StringUtil.isNotEmpty(endTime)) {
//				q.append(" and DATE_FORMAT(AuditDotime,'%Y-%m-%d') between ? and ?", startTime, endTime);
//			} else if (StringUtil.isNotEmpty(startTime) & StringUtil.isEmpty(endTime)) {
//				q.append(" and DATE_FORMAT(AuditDotime,'%Y-%m-%d') > ? ", startTime);
//			} else if (StringUtil.isEmpty(startTime) & StringUtil.isNotEmpty(endTime)) {
//				q.append(" and DATE_FORMAT(AuditDotime,'%Y-%m-%d') < ? ", endTime);
//			}
			q.append("order by PerjectTime ");
			q.append(" limit ?,?", pageIndex, pageSize);
			Q qTwo = new Q(
					"select count(*) as c from eao_audit AS zb LEFT JOIN eao_project_info AS ei on zb.ProjectId = ei.id where zb.Auditor = ? AND zb.Stats != '已审核'",
					auditor);
//			if (StringUtil.isNotEmpty(startTime) & StringUtil.isNotEmpty(endTime)) {
//				qTwo.append(" and DATE_FORMAT(AuditDotime,'%Y-%m-%d') between ? and ?", startTime, endTime);
//			} else if (StringUtil.isNotEmpty(startTime) & StringUtil.isEmpty(endTime)) {
//				qTwo.append(" and DATE_FORMAT(AuditDotime,'%Y-%m-%d') > ? ", startTime);
//			} else if (StringUtil.isEmpty(startTime) & StringUtil.isNotEmpty(endTime)) {
//				qTwo.append(" and DATE_FORMAT(AuditDotime,'%Y-%m-%d') < ? ", endTime);
//			}
			Integer count = 0;
			DataTable dt = qTwo.fetch();
			for (DataRow dr : dt) {
				count = dr.getInt("c");
			}
			this.Response.put("count", count);
			$S("data", q.fetch());
		} else if (stats.equals("已审核")) {
			Q q = new Q(
					"select eb.Name,ei.ID as Pid,ei.ProjectName,zb.Id,zb.ProjectId,ei.ProjectNumber,ei.ProjectLevel,ei.ReportType,ei.ApprovalUnit,ei.PerjectType as Stats,zb.AuditType,AuditDotime as AuditDate,zb.AuditScore from eao_audit AS zb LEFT JOIN eao_project_info AS ei on zb.projectId = ei.Id LEFT JOIN Mh_Branch as eb on ei.company = eb.company and ei.BranchInnerCode = eb.BranchInnerCode where zb.auditor = ? AND zb.stats = '已审核'",
					auditor);
			Q qTwo = new Q(
					"select count(*) as c from eao_audit AS zb LEFT JOIN eao_project_info AS ei on zb.projectId = ei.id where zb.auditor = ? AND zb.stats ='已审核' ",
					auditor);
			Q qThree = new Q(
					"select SUM(he) as jixiao,GROUP_CONCAT(zongshu ,'个',ReportType) as shuju from (select SUM(AuditScore) as he ,AuditDotime,auditor,COUNT(projectId) as zongshu,reportType from eao_audit INNER JOIN eao_project_info  on eao_audit.projectId = eao_project_info.Id  where eao_audit.stats = '已审核' ");
			if (StringUtil.isNotEmpty(startTime) & StringUtil.isNotEmpty(endTime)) {
				String sql = " and DATE_FORMAT(AuditDotime,'%Y-%m-%d') between ? and ?";
				q.append(sql, startTime, endTime);
				qTwo.append(sql, startTime, endTime);
				qThree.append(sql, startTime, endTime);
			} else if (StringUtil.isNotEmpty(startTime) & StringUtil.isEmpty(endTime)) {
				String sql = " and DATE_FORMAT(AuditDotime,'%Y-%m-%d') > ? ";
				q.append(sql, startTime);
				qTwo.append(sql, startTime);
				qThree.append(sql, startTime);
			} else if (StringUtil.isEmpty(startTime) & StringUtil.isNotEmpty(endTime)) {
				String sql = " and DATE_FORMAT(AuditDotime,'%Y-%m-%d') < ? ";
				q.append(sql, endTime);
				qTwo.append(sql, endTime);
				qThree.append(sql, endTime);
			}
			q.append("order by AuditDotime desc ");
			q.append(" limit ?,?", pageIndex, pageSize);
			qThree.append("and Auditor = ? GROUP BY Auditor , ReportType) as sssc  GROUP BY Auditor ", auditor);
			String sum = "";
			Integer score = 0;
			Integer count = 0;
			DataTable dtTwo = qTwo.fetch();
			for (DataRow drTwo : dtTwo) {
				count = drTwo.getInt("c");
			}
			DataTable dtThree = qThree.fetch();
			for (DataRow drThree : dtThree) {
				score = drThree.getInt("jixiao");
				sum = drThree.getString("shuju");
			}
			this.Response.put("count", count); // 总条数
			this.Response.put("score", score); // 绩效
			this.Response.put("sum", sum); // 报告书、表总数
			$S("data", q.fetch());
		}
	}

	/**
	 * 根据审核人统计涉及的项目
	 */
	@Priv(loginType = LoginType.Member)
	public void countAudit() {
		String auditor = ""; // 接收审核人信息 默认为登录人
		auditor = Long.toString(Member.getUID());
		// String stats = "已审核"; // 统计审核
		if (StringUtils.isEmpty(auditor)) {
			f("操作失败");
			return;
		}
		/*
		 * Q q = new Q(
		 * "SELECT report_type,COUNT(*) FROM eao_project_info  where report_type='报告表' AND id IN(SELECT project_id from eao_audit where auditor = ? AND stats = ? )UNION SELECT report_type,COUNT(*) FROM eao_project_info  where report_type='报告书' AND id IN(SELECT project_id from eao_audit where auditor = ? AND stats = ?)"
		 * , auditor, stats, auditor, stats); $S("data", q.fetch());
		 */
		Q qThree = new Q(
				"select SUM(he) as jixiao,GROUP_CONCAT(zongshu ,'个',ReportType) as shuju from (select SUM(AuditScore) as he ,AuditDotime,auditor,COUNT(projectId) as zongshu,reportType from eao_audit INNER JOIN eao_project_info  on eao_audit.projectId = eao_project_info.Id  where eao_audit.stats = '已审核' ");
		qThree.append("and Auditor = ? GROUP BY auditor , ReportType) as sssc  GROUP BY auditor ", auditor);
		String sum = "";
		Integer score = 0;
		DataTable dtThree = qThree.fetch();
		for (DataRow drThree : dtThree) {
			score = drThree.getInt("jixiao");
			sum = drThree.getString("shuju");
		}
		this.Response.put("bscore", score); // 绩效
		this.Response.put("bsum", sum); // 报告书、表总数
	}

	/**
	 * 根据id删除
	 */
	@Priv(loginType = LoginType.Member)
	public void deleteByid() {
		String id = $V("Id");
		if (!StringUtil.isNotEmpty(id)) {
			f("操作失败，请确认操作信息");
			return;
		}
		DataTable dt = new Q(" select * from eao_audit where Id = ?", id).fetch();
		EaoAudit old = new EaoAudit();
		old.setValue(dt.get(0));
		if (old.getStats().equals("已审核")) {
			f("审核已关闭，不可更改");
			return;
		}
		Transaction trans = new Transaction();
		Q qTwo = new Q(" delete from eao_audit  where ").in("id", id);
		trans.add(qTwo);
		if (trans.commit()) {
			s(Lang.get("Common.ExecuteSuccess"));
		} else {
			f(Lang.get("Common.ExecuteFailed"));
		}
	}

	/**
	 * 设置项目审核人员
	 */
	@Priv(loginType = LoginType.Member)
	public void setAuditor() {
		Transaction trans = new Transaction();
		String pid = $V("ProjectId");// 项目id

		String js; // 判读是否为分公司
		if (!StringUtil.isNotEmpty(pid)) {
			f("操作失败，请确认操作信息");
			return;
		}

		DataTable dt = new Q("Select Tof from eao_project_info where Id= ?", pid).fetch();
		js = dt.get(0, 0).toString();

		if (js.equals("1")) {
			String ysname = $V("Ysname"); // 一审工程师
			String esname = $V("Esname"); // 二审工程师
			DataTable ysdt = new Q(" select * from eao_audit where ProjectId = ? AND AuditType = ?", pid, "一审").fetch();
			DataTable esdt = new Q(" select * from eao_audit where ProjectId = ? AND AuditType = ?", pid, "二审").fetch();
			EaoAudit ysold = new EaoAudit();
			EaoAudit esold = new EaoAudit();
			ysold.setValue(ysdt.get(0));
			ysold.setAuditor(ysname);
			esold.setValue(esdt.get(0));
			esold.setAuditor(esname);
			trans.update(ysold);
			trans.update(esold);
		}
		String cname = $V("Cname"); // 初审人工程师
		String fname = $V("Fname");// 复审人工程师
		String zname = $V("Zname");// 终审人工程师
		DataTable cdt = new Q(" select * from eao_audit where ProjectId = ? AND AuditType = ?", pid, "初审").fetch();
		DataTable fdt = new Q(" select * from eao_audit where ProjectId = ? AND AuditType = ?", pid, "复审").fetch();
		DataTable zdt = new Q(" select * from eao_audit where ProjectId = ? AND AuditType = ?", pid, "终审").fetch();
		EaoAudit cold = new EaoAudit();
		EaoAudit fold = new EaoAudit();
		EaoAudit zold = new EaoAudit();
		cold.setValue(cdt.get(0));
		cold.setAuditor(cname);
		fold.setValue(fdt.get(0));
		fold.setAuditor(fname);
		zold.setValue(zdt.get(0));
		zold.setAuditor(zname);
		trans.update(cold);
		trans.update(fold);
		trans.update(zold);
		if (trans.commit()) {
			s(Lang.get("Common.ExecuteSuccess"));
		} else {
			f(Lang.get("Common.ExecuteFailed"));
		}
	}

	/**
	 * 根据项目id 审核状态 获取审核修改单数据
	 */
	@Priv(loginType = LoginType.Member)
	public void findByProject() {
		String projectId = $V("ProjectId");
		String atype = $V("Atype");
		if (!StringUtil.isNotEmpty(projectId)) {
			f("操作失败，请确认操作信息");
			return;
		}
		if (!StringUtil.isNotEmpty(atype)) {
			f("操作失败，请确认操作信息");
			return;
		}
		DataTable docDt = new Q(" select * from eao_project_doc where ProjectId = ?", projectId).fetch();
		EaoProjectDoc doc = new EaoProjectDoc();
		doc.setValue(docDt.get(0));
		this.Response.put("doc", doc);
		DataTable dtTwo = new Q(
				"  select epi.PerjectLeader as PerjectLeaderId,epi.ProjectNumber,epi.ProjectName,epi.BuildUnit,epi.ReportType,FullName as PerjectLeader,ProjectLevel,StaffNames,StaffNamesId,ReportOriginal from eao_project_info as epi LEFT JOIN(select GROUP_CONCAT(staffsName) as staffNames, GROUP_CONCAT(staffNameId) as staffNamesId , cy.projectId from(select staff.staffName as staffNameId , staff.projectId,FullName as staffsName from eao_project_staff as staff LEFT JOIN Mh_Resource on staff.staffName=Mh_Resource.Member)as cy GROUP BY projectId ) as stss on epi.Id = stss.projectId LEFT JOIN eao_project_doc as epd on epi.id = epd.projectId LEFT JOIN Mh_Resource as mr on epi.perjectLeader = mr.Member where epi.id = ?",
				projectId).fetch();
		String level = "";
		String project_number = "";
		String project_name = "";
		String build_unit = "";
		String report_type = "";
		String perject_leader = "";
		String perject_leaderId = "";
		String staff_names = "";
		String Report_original = "";
		String staff_namesId = "";
		for (DataRow drTwo : dtTwo) {
			level = drTwo.getString("ProjectLevel");
			project_number = drTwo.getString("ProjectNumber");
			project_name = drTwo.getString("ProjectName");
			build_unit = drTwo.getString("BuildUnit");
			report_type = drTwo.getString("ReportType");
			perject_leader = drTwo.getString("PerjectLeader");
			staff_names = drTwo.getString("StaffNames");
			Report_original = drTwo.getString("ReportOriginal");
			staff_namesId = drTwo.getString("StaffNamesId");
			perject_leaderId = drTwo.getString("PerjectLeaderId");
		}
		this.Response.put("Level", level);
		this.Response.put("ProjectNumber", project_number);
		this.Response.put("ProjectName", project_name);
		this.Response.put("BuildUnit", build_unit);
		this.Response.put("ReportType", report_type);
		this.Response.put("PerjectLeader", perject_leader);
		this.Response.put("StaffNames", staff_names);
		this.Response.put("StaffNamesId", staff_namesId);
		this.Response.put("PerjectLeaderId", perject_leaderId);
		this.Response.put("ReportOriginal", Report_original);

		if (atype.equals("0")) {
			atype = "一审";
			Q q = new Q(
					"select ea.Id,ea.ProjectId,mr.FullName as Audit,ea.Stats,ea.AuditType,mrs.FullName as Modifier from eao_audit as ea LEFT JOIN Mh_Resource as mr on ea.auditor = mr.Member LEFT JOIN Mh_Resource as mrs on ea.Modifier = mrs.Member  where ProjectId = ? and auditType =? ",
					projectId, atype);
			DataTable dt = q.fetch();
			String aid = dt.getString(0, "Id");
			String audit = dt.getString(0, "Audit");
			String modifier = dt.getString(0, "Modifier");
			String stats = dt.getString(0, "Stats");
			this.Response.put("Stats", stats);
			this.Response.put("Audit", audit);
			this.Response.put("Modifier", modifier);
			Q qOne = new Q(
					"select ear.Id,ear.AuditId,ear.AuditOpinion,ear.ReviseExplain,ear.AuditTime,ear.ChangeTime from eao_audit_reply as ear where AuditId = ? ORDER BY ear.AuditTime",
					aid);
			$S("Yishen", qOne.fetch());
		} else if (atype.equals("1")) {
			String type = "一审";
			Q qThree = new Q(
					"select ea.AuditDotime,ea.ModifierDotime,ea.Id,ea.projectId,mr.FullName as Audit,ea.Stats,ea.AuditType,mrs.FullName as Modifier from eao_audit as ea LEFT JOIN Mh_Resource as mr on ea.auditor = mr.Member LEFT JOIN Mh_Resource as mrs on ea.Modifier = mrs.Member  where ProjectId = ? and AuditType =? ",
					projectId, type);
			DataTable dtThree = qThree.fetch();
			String aidThree = "";
			String modifierThree = "";
			String atimeThree = "";
			String modifiertimeThree = "";
			for (DataRow drThree : dtThree) {
				aidThree = drThree.getString("Id");
				modifierThree = drThree.getString("Modifier");
				atimeThree = drThree.getString("AuditDotime");
				modifiertimeThree = drThree.getString("ModifierDotime");
			}
			this.Response.put("Modifier1", modifierThree);
			this.Response.put("Atime1", atimeThree);
			this.Response.put("Modifiertime1", modifiertimeThree);
			Q qFour = new Q(
					"select ear.Id,ear.AuditId,ear.AuditOpinion,ear.ReviseExplain,ear.AuditTime,ear.ChangeTime from eao_audit_reply as ear where AuditId = ? ORDER BY ear.AuditTime",
					aidThree);
			$S("Yishen", qFour.fetch());
			atype = "二审";
			Q q = new Q(
					"select ea.Id,ea.ProjectId,mr.FullName as Audit,ea.Stats,ea.AuditType,mrs.FullName as Modifier from eao_audit as ea LEFT JOIN Mh_Resource as mr on ea.auditor = mr.Member LEFT JOIN Mh_Resource as mrs on ea.Modifier = mrs.Member  where ProjectId = ? and AuditType =? ",
					projectId, atype);
			DataTable dt = q.fetch();
			String aid = dt.getString(0, "Id");
			String audit = dt.getString(0, "Audit");
			String modifier = dt.getString(0, "Modifier");
			String stats = dt.getString(0, "Stats");
			this.Response.put("Stats", stats);
			this.Response.put("Audit2", audit);
			this.Response.put("Modifier2", modifier);
			Q qOne = new Q(
					"select ear.Id,ear.AuditId,ear.AuditOpinion,ear.ReviseExplain,ear.AuditTime,ear.ChangeTime from eao_audit_reply as ear where AuditId = ? ORDER BY ear.AuditTime",
					aid);
			$S("Ershen", qOne.fetch());
		} else if (atype.equals("2")) {
			atype = "初审";
			Q q = new Q(
					"select ea.Id,ea.ProjectId,mr.FullName as Audit,ea.Stats,ea.AuditType,mrs.FullName as Modifier from eao_audit as ea LEFT JOIN Mh_Resource as mr on ea.auditor = mr.Member LEFT JOIN Mh_Resource as mrs on ea.Modifier = mrs.Member  where ProjectId = ? and auditType =? ",
					projectId, atype);
			DataTable dt = q.fetch();
			String aid = dt.getString(0, "Id");
			String audit = dt.getString(0, "Audit");
			String modifier = dt.getString(0, "Modifier");
			String stats = dt.getString(0, "Stats");
			this.Response.put("Stats", stats);
			this.Response.put("Caudit", audit);
			this.Response.put("CModifier", modifier);
			Q qOne = new Q(
					"select ear.Id,ear.AuditId,ear.AuditOpinion,ear.ReviseExplain,ear.AuditTime,ear.ChangeTime from eao_audit_reply as ear where AuditId = ? ORDER BY ear.AuditTime",
					aid);
			$S("Chushen", qOne.fetch());
			DataTable dtFour = qOne.fetch();
			Integer f = dtFour.getRowCount();
			String[] str = new String[f];
			Integer i = 0;
			for (DataRow dataRow : dtFour) {
				String opinion = dataRow.getString("AuditOpinion");
				str[i] = opinion;
				i++;
				$S("AuditOpinion", str);
			}
		} else if (atype.equals("3")) {
			String type = "初审";
			Q qThree = new Q(
					"select ea.AuditDotime,ea.ModifierDotime,ea.Id,ea.ProjectId,mr.FullName as Audit,ea.Stats,ea.AuditType,mrs.FullName as Modifier from eao_audit as ea LEFT JOIN Mh_Resource as mr on ea.auditor = mr.Member LEFT JOIN Mh_Resource as mrs on ea.Modifier = mrs.Member  where ProjectId = ? and auditType =? ",
					projectId, type);
			DataTable dtThree = qThree.fetch();
			String aidThree = "";
			String modifierThree = "";
			String atimeThree = "";
			String modifiertimeThree = "";
			for (DataRow drThree : dtThree) {
				aidThree = drThree.getString("Id");
				modifierThree = drThree.getString("Modifier");
				atimeThree = drThree.getString("AuditDotime");
				modifiertimeThree = drThree.getString("ModifierDotime");
			}
			this.Response.put("CAtime", atimeThree);
			this.Response.put("CModifiertime", modifiertimeThree);
			this.Response.put("CModifier", modifierThree);
			Q qFour = new Q(
					"select ear.Id,ear.AuditId,ear.AuditOpinion,ear.ReviseExplain,ear.AuditTime,ear.ChangeTime from eao_audit_reply as ear where AuditId = ? ORDER BY ear.AuditTime",
					aidThree);
			$S("Chushen", qFour.fetch());
			atype = "复审";
			Q q = new Q(
					"select ea.Id,ea.ProjectId,mr.FullName as Audit,ea.Stats,ea.AuditType,mrs.FullName as Modifier from eao_audit as ea LEFT JOIN Mh_Resource as mr on ea.auditor = mr.Member LEFT JOIN Mh_Resource as mrs on ea.Modifier = mrs.Member  where ProjectId = ? and auditType =? ",
					projectId, atype);
			DataTable dt = q.fetch();
			String aid = dt.getString(0, "Id");
			String audit = dt.getString(0, "Audit");
			String modifier = dt.getString(0, "Modifier");
			String stats = dt.getString(0, "Stats");
			this.Response.put("Stats", stats);
			this.Response.put("FAudit", audit);
			this.Response.put("FModifier", modifier);
			Q qOne = new Q(
					"select ear.Id,ear.AuditId,ear.AuditOpinion,ear.ReviseExplain,ear.AuditTime,ear.ChangeTime from eao_audit_reply as ear where AuditId = ? ORDER BY ear.AuditTime",
					aid);
			$S("Fushen", qOne.fetch());
		} else if (atype.equals("4")) {
			String type = "初审";
			Q qThree = new Q(
					"select ea.AuditDotime,ea.ModifierDotime,ea.Id,ea.ProjectId,mr.FullName as Audit,ea.Stats,ea.AuditType,mrs.FullName as Modifier from eao_audit as ea LEFT JOIN Mh_Resource as mr on ea.auditor = mr.Member LEFT JOIN Mh_Resource as mrs on ea.Modifier = mrs.Member  where ProjectId = ? and auditType =? ",
					projectId, type);
			DataTable dtThree = qThree.fetch();
			String aidThree = "";
			String modifierThree = "";
			String atimeThree = "";
			String modifiertimeThree = "";
			for (DataRow drThree : dtThree) {
				aidThree = drThree.getString("Id");
				modifierThree = drThree.getString("Modifier");
				atimeThree = drThree.getString("AuditDotime");
				modifiertimeThree = drThree.getString("ModifierDotime");
			}
			this.Response.put("CAtime", atimeThree);
			this.Response.put("CModifiertime", modifiertimeThree);
			this.Response.put("CModifier", modifierThree);
			Q qFour = new Q(
					"select ear.Id,ear.AuditId,ear.AuditOpinion,ear.ReviseExplain,ear.AuditTime,ear.ChangeTime from eao_audit_reply as ear where AuditId = ? ORDER BY ear.AuditTime",
					aidThree);
			$S("Chushen", qFour.fetch());
			String typeTwo = "复审";
			Q qFive = new Q(
					"select ea.AuditDotime,ea.ModifierDotime,ea.Id,ea.ProjectId,mr.FullName as Audit,ea.Stats,ea.AuditType,mrs.FullName as Modifier from eao_audit as ea LEFT JOIN Mh_Resource as mr on ea.auditor = mr.Member LEFT JOIN Mh_Resource as mrs on ea.Modifier = mrs.Member  where ProjectId = ? and auditType =? ",
					projectId, typeTwo);
			DataTable dtFive = qFive.fetch();
			String aidFive = "";
			String modifierFive = "";
			String atimeFive = "";
			String modifiertimeFive = "";
			for (DataRow drThree : dtFive) {
				aidFive = drThree.getString("Id");
				modifierFive = drThree.getString("Modifier");
				atimeFive = drThree.getString("AuditDotime");
				modifiertimeFive = drThree.getString("ModifierDotime");
			}
			this.Response.put("FAtime", atimeFive);
			this.Response.put("FModifiertime", modifiertimeFive);
			this.Response.put("FModifier", modifierFive);
			Q qSix = new Q(
					"select ear.Id,ear.AuditId,ear.AuditOpinion,ear.ReviseExplain,ear.AuditTime,ear.ChangeTime from eao_audit_reply as ear where AuditId = ? ORDER BY ear.AuditTime",
					aidFive);
			$S("Fushen", qSix.fetch());
			atype = "终审";
			Q q = new Q(
					"select ea.Id,ea.ProjectId,mr.FullName as Audit,ea.Stats,ea.AuditType,mrs.FullName as Modifier from eao_audit as ea LEFT JOIN Mh_Resource as mr on ea.auditor = mr.Member LEFT JOIN Mh_Resource as mrs on ea.Modifier = mrs.Member  where ProjectId = ? and auditType =? ",
					projectId, atype);
			DataTable dt = q.fetch();
			String aid = dt.getString(0, "Id");
			String audit = dt.getString(0, "Audit");
			String modifier = dt.getString(0, "Modifier");
			String stats = dt.getString(0, "Stats");
			this.Response.put("Stats", stats);
			this.Response.put("ZAudit", audit);
			this.Response.put("ZModifier", modifier);
			Q qOne = new Q(
					"select ear.Id,ear.AuditId,ear.AuditOpinion,ear.ReviseExplain,ear.AuditTime,ear.ChangeTime from eao_audit_reply as ear where AuditId = ? ORDER BY ear.AuditTime",
					aid);
			$S("Zhongshen", qOne.fetch());
		} else {
			f("操作失败，请确认操作信息");
			return;
		}
	}

	/**
	 * 根据项目id 审核状态 获取审核修改单数据
	 */
	@Priv(loginType = LoginType.Member)
	public void findByProject2() {
		String projectId = $V("ProjectId");
		String atype = $V("Atype");
		String btype = "";
		if (!StringUtil.isNotEmpty(projectId)) {
			f("操作失败，请确认操作信息");
			return;
		}
		if (!StringUtil.isNotEmpty(atype)) {
			f("操作失败，请确认操作信息");
			return;
		}
		if (atype.equals("0")) {
			atype = "一审";
			btype = "10";
		} else if (atype.equals("1")) {
			atype = "二审";
			btype = "11";
		} else if (atype.equals("2")) {
			atype = "初审";
			btype = "12";
		} else if (atype.equals("3")) {
			atype = "复审";
			btype = "13";
		} else if (atype.equals("4")) {
			atype = "终审";
			btype = "14";
		} else {
			f("操作失败，请确认操作信息");
			return;
		}
		DataTable docDt = new Q(" select * from eao_project_doc where projectId = ?", projectId).fetch();
		EaoProjectDoc doc = new EaoProjectDoc();
		doc.setValue(docDt.get(0));
		this.Response.put("doc", doc);
		Q q = new Q(
				"select ea.Auditor , ea.ModifierDotime,ea.Id,ea.ProjectId,mr.FullName as Audit,ea.Stats,ea.AuditType,(select realname from Ec_Member em where em.id=ea.Modifier) as RealName,ea.Modifier as Modifier from eao_audit as ea LEFT JOIN Mh_Resource as mr on ea.auditor = mr.Member  where ProjectId = ? and auditType =? ",
				projectId, atype);
		DataTable dt = q.fetch();
		String aid = "";
		String audit = "";
		String modifier = "";
		String modifiertime = "";
		String RealName = "";
		String auditor = "";
		String stats = "";
		for (DataRow dr : dt) {
			aid = dr.getString("Id");
			audit = dr.getString("Audit");
			modifier = dr.getString("Modifier");
			modifiertime = dr.getString("ModifierDotime");
			RealName = dr.getString("RealName");
			auditor = dr.getString("Auditor");
			stats = dr.getString("Stats");
		}
		System.out.println(RealName);
		this.Response.put("Stats", stats);
		this.Response.put("Auditor", auditor);
		this.Response.put("Audit", audit);
		this.Response.put("Modifier", modifier);
		this.Response.put("RealName", RealName);
		this.Response.put("ModifierDotime", modifiertime);

		DataTable dtTwo = new Q(
				"  select epi.PerjectLeader as PerjectLeaderId, epi.ProjectNumber,epi.ProjectName,epi.BuildUnit,epi.ReportType,FullName as PerjectLeader,ProjectLevel,StaffNames,StaffNamesId,ReportOriginal from eao_project_info as epi LEFT JOIN(select GROUP_CONCAT(staffsName) as staffNames,GROUP_CONCAT(staffName) as staffNamesId, cy.projectId from(select staff.staffName,staff.projectId,FullName as staffsName from eao_project_staff as staff LEFT JOIN Mh_Resource on staff.staffName=Mh_Resource.Member)as cy GROUP BY projectId ) as stss on epi.Id = stss.projectId LEFT JOIN eao_project_doc as epd on epi.Id = epd.projectId LEFT JOIN Mh_Resource as mr on epi.perjectLeader = mr.Member where epi.Id = ?",
				projectId).fetch();
		String level = "";
		String project_number = "";
		String project_name = "";
		String build_unit = "";
		String report_type = "";
		String perject_leader = "";
		String perject_leaderId = "";
		String staff_names = "";
		String staff_namesId = "";
		String Report_original = "";
		for (DataRow drTwo : dtTwo) {
			level = drTwo.getString("ProjectLevel");
			project_number = drTwo.getString("projectNumber");
			project_name = drTwo.getString("projectName");
			build_unit = drTwo.getString("BuildUnit");
			report_type = drTwo.getString("ReportType");
			perject_leader = drTwo.getString("perjectLeader");
			staff_names = drTwo.getString("StaffNames");
			Report_original = drTwo.getString("ReportOriginal");
			perject_leaderId = drTwo.getString("perjectLeaderId");
			staff_namesId = drTwo.getString("StaffNamesId");
		}
		this.Response.put("PerjectLeaderId", perject_leaderId);
		this.Response.put("StaffNamesId", staff_namesId);
		this.Response.put("Level", level);
		this.Response.put("ProjectNumber", project_number);
		this.Response.put("ProjectName", project_name);
		this.Response.put("BuildUnit", build_unit);
		this.Response.put("ReportType", report_type);
		this.Response.put("PerjectLeader", perject_leader);
		this.Response.put("StaffNames", staff_names);
		this.Response.put("ReportOriginal", Report_original);
		List<String> listOne = new ArrayList<String>();
		List<String> listTwo = new ArrayList<String>();

		Q qOne = new Q(
				"select DataTime from eao_project_submit_time as epct WHERE ProjectId =? AND ProjectType=? AND submitType=? ORDER BY DataTime",
				projectId, btype, "2");
		DataTable dtThree = qOne.fetch();
		int index = 1;
		for (DataRow dr : dtThree) {
			String convert = AuditUI.convert(index);
			String prefix = "第" + convert + "次" + dr.getString(0);
			listOne.add(prefix);
			index++;
		}
		$S("AuditTime", listOne);
		Q qTwo = new Q(
				"select DataTime from eao_project_submit_time as epct WHERE ProjectId =? AND ProjectType=? AND submitType=? ORDER BY DataTime",
				projectId, btype, "3");
		DataTable dtFour = qTwo.fetch();
		int indexTwo = 1;
		for (DataRow dr : dtFour) {
			String convert = AuditUI.convert(indexTwo);
			String prefix = "第" + convert + "次" + dr.getString(0);
			listTwo.add(prefix);
			indexTwo++;
		}
		$S("ChangeTime", listTwo);
		Q qThree = new Q(
				"select ear.Status, ear.Id,ear.AuditId,ear.AuditOpinion,ear.ReviseExplain,ear.AuditTime,ear.ChangeTime from eao_audit_reply as ear where AuditId = ? ORDER BY ear.AuditTime",
				aid);
		List<EaoAuditReply> list = new ArrayList<>();
		DataTable dataTable = qThree.fetch();
		for (DataRow dataRow : dataTable) {
			EaoAuditReply auditReply = new EaoAuditReply();
			auditReply.setValue(dataRow);
			if ("未提交".equals(stats)) {
				if ("1".equals(auditReply.getStatus())) {
					auditReply.setReviseExplain("");
				}
			}
			list.add(auditReply);
		}
		$S("data", list);

	}

	/**
	 * 根据项目id 审核状态 获取流程修改单数据
	 */
	@Priv(loginType = LoginType.Member)
	public void findByProject3() {
		String projectId = $V("ProjectId");
		String atype = $V("Atype");
		String btype = "";
		if (!StringUtil.isNotEmpty(projectId)) {
			f("操作失败，请确认操作信息");
			return;
		}
		if (!StringUtil.isNotEmpty(atype)) {
			f("操作失败，请确认操作信息");
			return;
		}
		if (atype.equals("0")) {
			atype = "一审";
			btype = "10";
		} else if (atype.equals("1")) {
			atype = "二审";
			btype = "11";
		} else if (atype.equals("2")) {
			atype = "初审";
			btype = "12";
		} else if (atype.equals("3")) {
			atype = "复审";
			btype = "13";
		} else if (atype.equals("4")) {
			atype = "终审";
			btype = "14";
		} else {
			f("操作失败，请确认操作信息");
			return;
		}
		DataTable docDt = new Q(" select * from eao_project_doc where projectId = ?", projectId).fetch();
		EaoProjectDoc doc = new EaoProjectDoc();
		doc.setValue(docDt.get(0));
		this.Response.put("doc", doc);
		Q q = new Q(
				"select ea.Auditor , ea.ModifierDotime,ea.Id,ea.ProjectId,mr.FullName as Audit,ea.Stats,ea.AuditType,(select realname from Ec_Member em where em.id=ea.Modifier) as RealName,ea.Modifier as Modifier from eao_audit as ea LEFT JOIN Mh_Resource as mr on ea.auditor = mr.Member  where ProjectId = ? and auditType =? ",
				projectId, atype);
		DataTable dt = q.fetch();
		String aid = "";
		String audit = "";
		String modifier = "";
		String modifiertime = "";
		String RealName = "";
		String auditor = "";
		String stats = "";
		for (DataRow dr : dt) {
			aid = dr.getString("Id");
			audit = dr.getString("Audit");
			modifier = dr.getString("Modifier");
			modifiertime = dr.getString("ModifierDotime");
			RealName = dr.getString("RealName");
			auditor = dr.getString("Auditor");
			stats = dr.getString("Stats");
		}
		System.out.println(RealName);
		this.Response.put("Stats", stats);
		this.Response.put("Auditor", auditor);
		this.Response.put("Audit", audit);
		this.Response.put("Modifier", modifier);
		this.Response.put("RealName", RealName);
		this.Response.put("ModifierDotime", modifiertime);

		DataTable dtTwo = new Q(
				"  select epi.PerjectLeader as Perject_leaderId, epi.ProjectNumber,epi.ProjectName,epi.BuildUnit,epi.ReportType,FullName as PerjectLeader,ProjectLevel,StaffNames,StaffNamesId,ReportOriginal from eao_project_info as epi LEFT JOIN(select GROUP_CONCAT(staffsName) as staffNames,GROUP_CONCAT(staffName) as staffNamesId, cy.projectId from(select staff.staffName,staff.projectId,FullName as staffsName from eao_project_staff as staff LEFT JOIN Mh_Resource on staff.staffName=Mh_Resource.Member)as cy GROUP BY projectId ) as stss on epi.Id = stss.projectId LEFT JOIN eao_project_doc as epd on epi.Id = epd.projectId LEFT JOIN Mh_Resource as mr on epi.perjectLeader = mr.Member where epi.id = ?",
				projectId).fetch();
		String level = "";
		String project_number = "";
		String project_name = "";
		String build_unit = "";
		String report_type = "";
		String perject_leader = "";
		String perject_leaderId = "";
		String staff_names = "";
		String staff_namesId = "";
		String Report_original = "";
		for (DataRow drTwo : dtTwo) {
			level = drTwo.getString("ProjectLevel");
			project_number = drTwo.getString("ProjectNumber");
			project_name = drTwo.getString("ProjectName");
			build_unit = drTwo.getString("BuildUnit");
			report_type = drTwo.getString("ReportType");
			perject_leader = drTwo.getString("PerjectLeader");
			staff_names = drTwo.getString("StaffNames");
			Report_original = drTwo.getString("ReportOriginal");
			perject_leaderId = drTwo.getString("Perject_leaderId");
			staff_namesId = drTwo.getString("StaffNamesId");
		}
		this.Response.put("PerjectLeaderId", perject_leaderId);
		this.Response.put("StaffNamesId", staff_namesId);
		this.Response.put("Level", level);
		this.Response.put("ProjectNumber", project_number);
		this.Response.put("ProjectName", project_name);
		this.Response.put("BuildUnit", build_unit);
		this.Response.put("ReportType", report_type);
		this.Response.put("PerjectLeader", perject_leader);
		this.Response.put("StaffNames", staff_names);
		this.Response.put("ReportOriginal", Report_original);
		List<String> listOne = new ArrayList<String>();
		List<String> listTwo = new ArrayList<String>();

		Q qOne = new Q(
				"select DataTime from eao_project_submit_time as epct WHERE projectId =? AND ProjectType=? AND submitType=? ORDER BY DataTime",
				projectId, btype, "2");
		DataTable dtThree = qOne.fetch();
		int index = 1;
		for (DataRow dr : dtThree) {
			String convert = AuditUI.convert(index);
			String prefix = "第" + convert + "次" + dr.getString(0);
			listOne.add(prefix);
			index++;
		}
		$S("AuditTime", listOne);
		Q qTwo = new Q(
				"select DataTime from eao_project_submit_time as epct WHERE projectId =? AND ProjectType=? AND submitType=? ORDER BY DataTime",
				projectId, btype, "3");
		DataTable dtFour = qTwo.fetch();
		int indexTwo = 1;
		for (DataRow dr : dtFour) {
			String convert = AuditUI.convert(indexTwo);
			String prefix = "第" + convert + "次" + dr.getString(0);
			listTwo.add(prefix);
			indexTwo++;
		}
		$S("ChangeTime", listTwo);
		Q qThree = new Q(
				"select ear.Id,ear.AuditId,ear.AuditOpinion,ear.ReviseExplain,ear.AuditTime,ear.ChangeTime from eao_audit_reply as ear where AuditId = ? ",
				aid);
		if ("审核中".equals(stats)) {
			qThree.append(" and ear.Status <> 1");
		}
		qThree.append(" ORDER BY ear.AuditTime");
		$S("data", qThree.fetch());

	}

	/**
	 * 根据项目id 获取所有审核状态修改单数据
	 */
	@Priv(loginType = LoginType.Member)
	public void findProjectAlltype() {
		String projectId = $V("ProjectId");
		if (!StringUtil.isNotEmpty(projectId)) {
			f("操作失败，请确认操作信息");
			return;
		}
		String[] types = { "一审", "二审", "初审", "复审", "终审" };
		for (int i = 0; i < types.length; i++) {

			Q q = new Q(
					"select ea.Id,ea.ProjectId,mr.FullName as Audit,ea.Stats,ea.AuditType,mrs.FullName as Modifier from eao_audit as ea LEFT JOIN Mh_Resource as mr on ea.auditor = mr.Member LEFT JOIN Mh_Resource as mrs on ea.Modifier = mrs.Member  where ProjectId = ? and auditType =? ",
					projectId, types[i]);
			DataTable dt = q.fetch();
			String aid = dt.getString(0, "Id");
			String audit = dt.getString(0, "Audit");
			String modifier = dt.getString(0, "Modifier");
			Q qOne = new Q(
					"select ear.Id,ear.AuditId,ear.AuditOpinion,ear.ReviseExplain,ear.AuditTime,ear.ChangeTime from eao_audit_reply as ear where AuditId = ? ORDER BY ear.AuditTime",
					aid);
			this.Response.put("Audit" + i, audit);
			this.Response.put("Modifier" + i, modifier);
			this.Response.put("data" + i, qOne.fetch());
		}
	}

	/**
	 * 项目提交审核并 更改项目状态为审核中（项目负责人调用）
	 */
	@Priv(loginType = LoginType.Member)
	public void isAudit() {
		String projectId = $V("ProjectId");
		String atype = $V("Atype");
		String save = $V("Save");
		if (!StringUtil.isNotEmpty(projectId)) {
			f("操作失败，请确认操作信息");
			return;
		}
		if (!StringUtil.isNotEmpty(atype)) {
			f("操作失败，请确认操作信息");
			return;
		}
		DataTable dtTwo = new Q("select Tof from eao_project_info where id =? ", projectId).fetch();
		String level = dtTwo.getString(0, "Tof");
		if (atype.equals("0")) {
			atype = "一审";
		} else if (atype.equals("1")) {
			atype = "二审";
		} else if (atype.equals("2")) {
			atype = "初审";
		} else if (atype.equals("3")) {
			atype = "复审";
		} else if (atype.equals("4")) {
			atype = "终审";
		} else {
			f("操作失败，请确认操作信息");
			return;
		}
		DataTable dt = new Q("select * from eao_audit where ProjectId = ? and AuditType = ?", projectId, atype).fetch();
		EaoAudit old = new EaoAudit();
		old.setValue(dt.get(0));
		if (old.getStats().equals("已审核")) {
			f("审核已关闭");
			return;
		}
		if (old.getStats().equals("审核中")) {
			f("审核已开始");
			return;
		}
		if (level.equals("1")) {
			if (old.getAuditType().equals("二审")) {
				String pid = old.getProjectId();
				DataTable dta = new Q("select * from eao_audit where ProjectId = ? and AuditType = ?", pid, "一审")
						.fetch();
				EaoAudit exentity = new EaoAudit();
				exentity.setValue(dta.get(0));
				if (exentity.getStats().equals("审核中") || exentity.getStats().equals("未提交")) {
					f("未到此审核阶段不可提交");
					return;
				}
			}
			if (old.getAuditType().equals("初审")) {
				String pid = old.getProjectId();
				DataTable dta = new Q("select * from eao_audit where ProjectId = ? and AuditType = ?", pid, "二审")
						.fetch();
				EaoAudit exentity = new EaoAudit();
				exentity.setValue(dta.get(0));
				if (exentity.getStats().equals("审核中") || exentity.getStats().equals("未提交")) {
					f("未到此审核阶段不可提交");
					return;
				}
			}
		}
		if (old.getAuditType().equals("复审")) {
			String pid = old.getProjectId();
			DataTable dta = new Q("select * from eao_audit where ProjectId = ? and AuditType = ?", pid, "初审").fetch();
			EaoAudit exentity = new EaoAudit();
			exentity.setValue(dta.get(0));
			if (exentity.getStats().equals("审核中") || exentity.getStats().equals("未提交")) {
				f("未到此审核阶段不可提交");
				return;
			}
		}
		if (old.getAuditType().equals("终审")) {
			String pid = old.getProjectId();
			DataTable dta = new Q("select * from eao_audit where ProjectId = ? and AuditType = ?", pid, "复审").fetch();
			EaoAudit exentity = new EaoAudit();
			exentity.setValue(dta.get(0));
			if (exentity.getStats().equals("审核中") || exentity.getStats().equals("未提交")) {
				f("未到此审核阶段不可提交");
				return;
			}
		}
		old.setValue(this.Request);
		Transaction transaction = new Transaction();
		if (StringUtil.isNotEmpty(save)) {
			old.setStats("审核中");
		}
		transaction.update(old);
		if (transaction.commit()) {
			s(Lang.get("Common.ExecuteSuccess"));
		} else {
			f(Lang.get("Common.ExecuteFailed"));
		}
	}

	/**
	 * 项目提交审核并 更改项目状态为已审核/未提交（审核人调用）
	 */
	@Priv(loginType = LoginType.Member)
	public void isAuditb() {
		String projectId = $V("ProjectId");
		String btype = $V("Btype");
		String isOk = $V("OK"); // 0已审核 1未提交
		String save = $V("Save");
		String yijian = $V("AuditReplyLists");
		Integer perjectType = null;
		if (!StringUtil.isNotEmpty(projectId)) {
			f("操作失败，请确认操作信息");
			return;
		}
		if (!StringUtil.isNotEmpty(btype)) {
			f("操作失败，请确认操作信息");
			return;
		}
		if (!StringUtil.isNotEmpty(isOk)) {
			f("操作失败，请确认操作信息");
			return;
		}
		DataTable dtTwo = new Q("select Tof from eao_project_info where Id =? ", projectId).fetch();
		String level = dtTwo.getString(0, "Tof");
		if (btype.equals("0") && level.equals("1")) {
			btype = "一审";
			perjectType = 7;
		} else if (btype.equals("1") && level.equals("1")) {
			btype = "二审";
			perjectType = 8;
		} else if (btype.equals("2")) {
			btype = "初审";
			perjectType = 9;
		} else if (btype.equals("3")) {
			btype = "复审";
			perjectType = 10;
		} else if (btype.equals("4")) {
			btype = "终审";
			perjectType = 11;
		} else {
			f("操作失败，请确认操作信息");
			return;
		}
		DataTable dt = new Q("select * from eao_audit where ProjectId = ? and AuditType = ?", projectId, btype).fetch();
		EaoAudit old = new EaoAudit();
		old.setValue(dt.get(0));
		if (old.getStats().equals("已审核")) {
			f("审核已关闭");
			return;
		}
		if (old.getStats().equals("未提交")) {
			f("审核未开始");
			return;
		}
		if (StringUtils.isEmpty(yijian)) {
			f("请输入审核意见");
			return;
		}
		if (level.equals("1")) {
			if (old.getAuditType().equals("二审")) {
				String pid = old.getProjectId();
				DataTable dta = new Q("select * from eao_audit where ProjectId = ? and AuditType = ?", pid, "一审")
						.fetch();
				EaoAudit exentity = new EaoAudit();
				exentity.setValue(dta.get(0));
				if (exentity.getStats().equals("审核中") || exentity.getStats().equals("未提交")) {
					f("未到此审核阶段不可提交");
					return;
				}
			}
			if (old.getAuditType().equals("初审")) {
				String pid = old.getProjectId();
				DataTable dta = new Q("select * from eao_audit where ProjectId = ? and AuditType = ?", pid, "二审")
						.fetch();
				EaoAudit exentity = new EaoAudit();
				exentity.setValue(dta.get(0));
				if (exentity.getStats().equals("审核中") || exentity.getStats().equals("未提交")) {
					f("未到此审核阶段不可提交");
					return;
				}
			}
		}
		if (old.getAuditType().equals("复审")) {
			String pid = old.getProjectId();
			DataTable dta = new Q("select * from eao_audit where ProjectId = ? and AuditType = ?", pid, "初审").fetch();
			EaoAudit exentity = new EaoAudit();
			exentity.setValue(dta.get(0));
			if (exentity.getStats().equals("审核中") || exentity.getStats().equals("未提交")) {
				f("未到此审核阶段不可提交");
				return;
			}
		}
		if (old.getAuditType().equals("终审")) {
			String pid = old.getProjectId();
			DataTable dta = new Q("select * from eao_audit where ProjectId = ? and AuditType = ?", pid, "复审").fetch();
			EaoAudit exentity = new EaoAudit();
			exentity.setValue(dta.get(0));
			if (exentity.getStats().equals("审核中") || exentity.getStats().equals("未提交")) {
				f("未到此审核阶段不可提交");
				return;
			}
		}
		old.setValue(this.Request);
		Transaction transaction = new Transaction();
		if (isOk.equals("0")) {
			old.setStats("已审核");
			Transaction tran = new Transaction();
			Q delete = new Q(" DELETE FROM eao_audit_reply WHERE AuditId = ? and status <> 3", old.getId());
			Q q = new Q(" UPDATE eao_project_info SET PerjectType = ? WHERE Id = ?", perjectType, projectId);
			tran.add(q);
			tran.add(delete);
			tran.commit();
		} else if (isOk.equals("1")) {
			if (StringUtil.isNotEmpty(save)) {
				old.setStats("未提交");
			}
		} else {
			f("操作失败，请确认操作信息");
			return;
		}
		Date data = new Date();
		SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		old.setAuditDotime(sd.format(data));
		transaction.update(old);
		if (transaction.commit()) {
			s(Lang.get("Common.ExecuteSuccess"));
		} else {
			f(Lang.get("Common.ExecuteFailed"));
		}
	}

	/**
	 * 获取项目流程单数据
	 */
	@Priv(loginType = LoginType.Member)
	public void findSubmitTime() {
		// 接收项目信息
		String pid = $V("ProjectId");
		if (!StringUtil.isNotEmpty(pid)) {
			f("操作失败，请确认操作信息");
			return;
		}
		DataTable dts = new Q(
				"select projectType,DataTime,submitType AS Atime , Operate from eao_project_submit_time as epct WHERE projectId =? GROUP BY projectType,submitType,DataTime ORDER BY ProjectType",
				pid).fetch();
		List<EaoSubmitTimeVo> lists = new ArrayList<EaoSubmitTimeVo>();
		for (int i = 0; i < 10; i++) {
			List<String> listOne = new ArrayList<String>();
			List<String> listTwo = new ArrayList<String>();
			for (DataRow dr : dts) {
				int Atype = dr.getInt("projectType");
				int Btype = dr.getInt("Atime");
				String time = dr.getString("DataTime");
				String Operate = dr.getString("Operate");
				if (i == Atype) {
					if (0 == Btype) {
						listOne.add(Operate + ":" + time);
					} else {
						listTwo.add(Operate + ":" + time);
					}
				}
			}

			EaoSubmitTimeVo entity = new EaoSubmitTimeVo();
			switch (i) {
			case 0:
				entity.setName("创建项目");
				entity.setSaveTime(listOne);
				entity.setSubmitTime(listTwo);
				lists.add(entity);
				break;
			case 1:
				entity.setName("资料收集");
				entity.setSaveTime(listOne);
				entity.setSubmitTime(listTwo);
				lists.add(entity);
				break;
			case 2:
				entity.setName("现场踏勘");
				entity.setSaveTime(listOne);
				entity.setSubmitTime(listTwo);
				lists.add(entity);
				break;
			case 3:
				entity.setName("环境质量及监测");
				entity.setSaveTime(listOne);
				entity.setSubmitTime(listTwo);
				lists.add(entity);
				break;
			case 4:
				entity.setName("报告编制及审核");
				entity.setSaveTime(listOne);
				entity.setSubmitTime(listTwo);
				lists.add(entity);
				break;
			case 5:
				entity.setName("报告送审");
				entity.setSaveTime(listOne);
				entity.setSubmitTime(listTwo);
				lists.add(entity);
				break;
			case 6:
				entity.setName("技术评估");
				entity.setSaveTime(listOne);
				entity.setSubmitTime(listTwo);
				lists.add(entity);
				break;
			case 7:
				entity.setName("报告报批");
				entity.setSaveTime(listOne);
				entity.setSubmitTime(listTwo);
				lists.add(entity);
				break;
			case 8:
				entity.setName("报告公示");
				entity.setSaveTime(listOne);
				entity.setSubmitTime(listTwo);
				lists.add(entity);
				break;
			case 9:
				entity.setName("报告存档");
				entity.setSaveTime(listOne);
				entity.setSubmitTime(listTwo);
				lists.add(entity);
				break;
			default:
				break;
			}
		}
		this.Response.put("data", lists);
	}

	/**
	 * 获取审核是否是第一次审核
	 */
	@Priv(loginType = LoginType.Member)
	public void findStats() {
		String aid = $V("AuditID");
		String projectId = $V("ProjectId");
		String atype = $V("AuditType");
		if (!StringUtil.isNotEmpty(aid)) {
			f("操作失败，请确认操作信息");
			return;
		}
		if (!StringUtil.isNotEmpty(projectId)) {
			f("操作失败，请确认操作信息");
			return;
		}
		if (!StringUtil.isNotEmpty(atype)) {
			f("操作失败，请确认操作信息");
			return;
		}
		DataTable dt = new Q("select COUNT(ear.AuditOpinion)AS CN from eao_audit_reply as ear where AuditId =? ", aid)
				.fetch();
		String stats = dt.get(0, "CN").toString();
		this.Response.put("stats", stats);
		if (stats.equals("0")) {
			Q q = new Q(
					"select ea.id,ea.projectId,mr.FullName as audit,ea.stats,ea.auditType,mrs.FullName as Modifier from eao_audit as ea LEFT JOIN Mh_Resource as mr on ea.auditor = mr.Member LEFT JOIN Mh_Resource as mrs on ea.Modifier = mrs.Member  where ProjectId = ? and auditType =? ",
					projectId, atype);
			DataTable dtOne = q.fetch();
			String aidTwo = dtOne.getString(0, "id");
			String audit = dtOne.getString(0, "audit");
			String modifier = dtOne.getString(0, "Modifier");
			Q qOne = new Q(
					"select ear.Id,ear.AuditId,ear.AuditOpinion,ear.ReviseExplain,ear.AuditTime,ear.ChangeTime from eao_audit_reply as ear where AuditId = ? ORDER BY ear.AuditTime",
					aidTwo);
			this.Response.put("audit", audit);
			this.Response.put("Modifier", modifier);
			$S("data", qOne.fetch());
		} else {
			String[] types = { "一审", "二审", "初审", "复审", "终审" };
			for (int i = 0; i < types.length; i++) {

				Q q = new Q(
						"select ea.id,ea.projectId,mr.FullName as audit,ea.stats,ea.auditType,mrs.FullName as Modifier from eao_audit as ea LEFT JOIN Mh_Resource as mr on ea.auditor = mr.Member LEFT JOIN Mh_Resource as mrs on ea.Modifier = mrs.Member  where ProjectId = ? and auditType =? ",
						projectId, types[i]);
				DataTable dts = q.fetch();
				String aidTwo = dts.getString(0, "id");
				String audit = dts.getString(0, "audit");
				String modifier = dts.getString(0, "Modifier");
				Q qOne = new Q(
						"select ear.Id,ear.AuditId,ear.AuditOpinion,ear.ReviseExplain,ear.AuditTime,ear.ChangeTime from eao_audit_reply as ear where AuditId = ? ORDER BY ear.AuditTime",
						aidTwo);
				this.Response.put("audit" + i, audit);
				this.Response.put("Modifier" + i, modifier);
				this.Response.put("data" + i, qOne.fetch());
			}
		}
	}

	/**
	 * 判断进入审核、修改页面
	 */
	@Priv(loginType = LoginType.Member)
	public void isChange() {
		String aid = $V("Id");
		DataTable dt = new Q("select COUNT(ear.AuditOpinion)AS CN from eao_audit_reply as ear where AuditId =? ", aid)
				.fetch();
		String stats = dt.get(0, "CN").toString();
		this.Response.put("stats", stats);
	}

	/**
	 * 判断审核状态
	 */
	@Priv(loginType = LoginType.Member)
	public void isAuditUp() {
		String projectId = $V("Id");
		String stats = $V("AuditType");
		String type = new Q(" select stats from eao_audit where projectId = ? and auditType = ?", projectId, stats)
				.executeString();
		this.Response.put("Stats", type);
	}

	public static String convert(int number) {
		// 数字对应的汉字
		String[] num = { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" };
		// 单位
		String[] unit = { "", "十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千", "万亿" };
		// 将输入数字转换为字符串
		String result = String.valueOf(number);
		// 将该字符串分割为数组存放
		char[] ch = result.toCharArray();
		// 结果 字符串
		String str = "";
		int length = ch.length;
		for (int i = 0; i < length; i++) {
			int c = (int) ch[i] - 48;
			if (c != 0) {
				str += num[c] + unit[length - i - 1];
			} else {
				str += num[c];
			}
		}
		return str;
	}
}
